/**
 * Created by kamlyli on 2017/8/6.
 */

export default class UiUtil {
  static loading (time, title) {
    wx.showToast({
      title: title || '正在加载....',
      icon: 'loading',
      duration: time * 1
    })
  }

  static success (time, title) {
    wx.showToast({
      title: title || '正在加载....',
      icon: 'success',
      duration: time * 1
    })
  }

  static showModal (title, content, showCancel) {
    return new Promise(function (resolve, reject) {
      wx.showModal({
        title: title,
        content: content,
        showCancel: showCancel,
        success: function (res) {
          if (res.confirm) {
            resolve(1)
          } else if (res.cancel) {
            resolve(0)
          }
        }
      })
    })
  }

}
